//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package come.tool.JDialog;

import java.awt.Color;

import javax.swing.BorderFactory;
import javax.swing.JTextField;

import com.tool.image.ImageMixDeal;
import org.come.Frame.ZhuFrame;
import org.come.Jpanel.GiveJpanel;
import org.come.bean.Bbuy;
import org.come.bean.GiveGoodsBean;
import org.come.entity.Goodstable;
import org.come.socket.Agreement;
import org.come.socket.SendMessageUntil;
import org.come.until.AccessSuitMsgUntil;
import org.come.until.GoodsListFromServerUntil;
import org.come.until.Goodtype;
import org.come.until.GsonUtil;
import org.come.until.UserMessUntil;
import org.come.until.Util;

import com.tool.Document.NumberDocument;
import com.tool.btn.BaptizeBtn;
import com.tool.image.ManimgAttribute;

public class SellAllGoodJDialog implements TiShiChuLi {
	
	private static boolean flag = false;// 
    
    public SellAllGoodJDialog() {
    }
    @Override
    public void tipBox(boolean tishi, Object object) {
        if (tishi) {
            this.clearAllBack();
        }

    }

    public void clearAllBack() {
        if (ImageMixDeal.userimg.getRoleShow().getBooth_id() != null) {
            ZhuFrame.getZhuJpanel().addPrompt2("摆摊状态不可以回收！");
            return;
        }
        if (!Util.isCanBuyOrno()) {
            int page = GoodsListFromServerUntil.Pagenumber;
            //一键回收
            for(int i = 0; i < 24; ++i) {
                Goodstable good = GoodsListFromServerUntil.getGoodslist()[i + page * 24];
                if (good != null) {
                    if (good.getGoodlock() == 1) {
//                        ZhuFrame.getZhuJpanel().addPrompt("物品#G" + good.getGoodsname() + "#Y已加锁，不可回收");
                    } else if (Goodtype.EquipmentType(good.getType()) != -1 && AccessSuitMsgUntil.getExtra(good.getValue(), BaptizeBtn.Extras[4]) != null) {
//                        ZhuFrame.getZhuJpanel().addPrompt2("物品#G" + good.getGoodsname() + "#Y已镶嵌宝石无法回收");
                    } else {
                    	giveshipolan(2, good.getUsetime(), good);
                        giveshipolan(1, good.getUsetime(), good);
                    }
                }
            }

            if(!flag) {
            	ZhuFrame.getZhuJpanel().addPrompt("当前背包页没有可回收的道具！");
            }
        }
    }
    
    
    /**绑玉回收 */
	public void giveshipolan(int type,int count,Goodstable giveGood) {
		//设置给与的时候获取的金钱
		Bbuy bbuy = UserMessUntil.getBbuy(giveGood.getGoodsid());
		if (bbuy == null || (bbuy.getPrice1() == 0 && type == 1) || (bbuy.getPrice2() == 0 && type == 2)) {
//			ZhuFrame.getZhuJpanel().addPrompt2("不属于回收范围");
			return;
		}else {
			flag=true;
			GiveGoodsBean givebean = new GiveGoodsBean();
			givebean.setType(type);
			givebean.setRgid(giveGood.getRgid());
			givebean.setSum(count);
			String senmes = Agreement.getAgreement().giveAgreement(GsonUtil.getGsonUtil().getgson().toJson(givebean));
			SendMessageUntil.toServer(senmes);// 向服务器发送信息
			ZhuFrame.getZhuJpanel().addPrompt("物品#G【" + giveGood.getGoodsname() + "】#Y数量#G【"+giveGood.getUsetime()+"】#Y回收成功！");
			flag=false;
		}
		
	}   
}
